function displayfields (x, indent = "")
  if (isempty (indent))
    printf ("%s: ", inputname (1))
  endif
  if (isstruct (x))
    printf ("structure containing:\n");
    indent = [indent "   "];
    nn = fieldnames (x);
    for ii = 1:numel(nn)
      if (isstruct (x.(nn{ii})))
        printf ("%s%s: ", indent, nn{ii});
        displayfields (x.(nn{ii}), indent)
      else
        printf ("%s%-10s  %dx%d %s\n", indent, nn{ii}, size(x.(nn{ii})), class(x.(nn{ii})))
      endif
    endfor
  else
    display ("not a structure");
  endif
endfunction